<template>
    <div class="big">
        <!-- 导航栏 -->
        <div class="navigation">
            <span @click="back">
                <img src="../../assets/home-img/返回1.png" alt="">
            </span>
            <h3>图文咨询</h3>
            <span></span>
        </div>
        <!-- 选择 -->
        <h2 class="select">请选择为谁咨询</h2>
        <!-- 患者 -->
        <div class="patient">
            <div v-for="(item, index) in filesList" :key="index" @click="toPay(item)">
                <div class="patientItem">
                    <h3>{{ item.name }} <span>({{ item.relationship }})</span> </h3>
                    <p>{{ item.age }}&ensp;{{ item.sex }}&ensp;{{ item.tel }}</p>
                </div>
                <img src="../../assets/home-img/虚线边框.png" alt="">
            </div>
            <p class="add" @click="addFiles">+ 添加</p>
        </div>
        <!-- 信息确认 -->
        <main>
            <div class="information">
                <span>首诊信息确认</span>
                <span class="fill">未填写 > </span>
            </div>
        </main>
        <!-- 问诊 -->
        <div class="consultation">
            <p>
                <van-checkbox v-model="checked">
                    我已阅读并同意
                    <span>《风险告知及患者知情通知书》</span>
                </van-checkbox>
            </p>
            <button @click="start">开始问诊</button>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router';
import http from '../../http/http'

const route = useRoute()
const router = useRouter()
const checked = ref(false);
const filesList = ref([]);
const payid = ref(0);
const payname = ref('')

const getFilesList = async () => {
    await http.get('/archive').then(res => {
        filesList.value = res.data.data
        console.log('====================================');
        console.log(filesList.value);
        console.log('====================================');
    })
}

const toPay = (item) => {
    payid.value = 60
    payname.value = item.name
}

// 支付
const start = () => {
    if (checked.value) {
        router.push({ path: '/pay', query: { money: payid.value, name: payname.value } })
    } else {
        showToast('请先阅读并同意《风险告知及患者知情通知书》');
    }
}


const showToast = (msg) => {
    ElMessage({
        message: msg,
        type: 'warning',
    })

}

const addFiles = () => {
    router.push('/xjda')
}

const back = () => {
    router.back();
}

onMounted(() => {
    getFilesList();
})
</script>

<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.big {
    width: 100%;
    height: 100%;

    .navigation {
        width: 100%;
        height: 92px;
        display: flex;
        justify-content: space-around;
        align-items: center;

        h3 {
            flex: 1;
            text-align: center;
            font-size: 35px;
        }

        span {
            width: 40px;
            padding-top: 7px;

            img {
                width: 40px;
                height: 40px;
                margin: 0 10px;
            }
        }
    }

    .select {
        width: 100%;
        line-height: 70px;
        padding: 0 20px;
    }

    .patient {
        width: 100%;
        padding: 0 20px;
        margin-top: 20px;
        display: flex;
        justify-content: space-around;
        flex-wrap: wrap;

        .add {
            width: 320px;
            height: 130px;
            line-height: 130px;
            text-align: center;
            border: 3px dashed #ccc;
            border-radius: 10px;
            border-image: repeating-linear-gradient(135deg,
                    #ccc,
                    #ccc 20px,
                    transparent 20px,
                    transparent 30px) 1;

            font-size: 35px;
            color: #9a9a9a;
        }

        div {
            width: 320px;
            height: 130px;
            margin-bottom: 20px;
            
            // border: 3px dashed #ccc;
            // border-image: repeating-linear-gradient(135deg,
            //         #ccc,
            //         #ccc 20px,
            //         transparent 20px,
            //         transparent 30px) 1;
            border-radius: 20px;
            font-size: 35px;
            position: relative;

            div {
                width: 100%;
                height: 100%;
                padding: 0 20px;
                padding-top: 20px;
                background-color: #fff;
                z-index: 9999;

                h3 {
                    width: 100%;
                    line-height: 40px;
                    font-size: 30px;
                }

                span {
                    font-weight: normal;
                    font-size: 25px;
                    color: #969696;
                }

                p {
                    font-size: 25px;
                    line-height: 60px;
                    color: #969696;
                }
            }

            img {
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                // height: 100%;
                height: 130px;
            }
        }
    }

    main {
        width: 100%;
        padding: 0 20px;
        padding-top: 30px;

        .information {
            width: 100%;
            line-height: 100px;
            padding: 0 20px;
            border-top: 1px solid #ccc;
            border-bottom: 1px solid #ccc;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .fill {
            color: #949494;
        }
    }

    .consultation {
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 150px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        button {
            width: 90%;
            height: 70px;
            border: 0;
            border-radius: 10px;
            margin-top: 10px;
            font-size: 30px;
            color: #fff;
            background-color: #b4ccf8;
        }
    }
}
</style>
